import book.BookList;
import users.AdminUser;
import users.NormalUser;
import users.User;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏李涛
 * Date: 2024-05-26
 * Time: 11:57
 */
public class Main {
    public static User register() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你的名字");
        String name = scanner.nextLine();

        System.out.println("请输入你的身份 1：管理员 ：2：普通用户");
        int choice = scanner.nextInt();
        if (choice == 1) {
            return new AdminUser(name);//通过构造方法，调用菜单

        }else {
            return new NormalUser(name);
        }
    }


    public static void main(String[] args) {
        BookList bookList = new BookList();

        User user = register();//这里通过父类，调用子类，实现动态绑定

        while (true) {
            int choice = user.menu();////通过菜单里返回信息，调用恰当操作
            user.DOperation(bookList, choice);
        }

    }
}

